package com.bianmaba.examples.mybatis.service;

import com.bianmaba.examples.mybatis.bean.order.Order;
import com.bianmaba.examples.mybatis.mapper.OrderMapper;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import org.mockito.internal.matchers.Or;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * @program: bianmaba-web-framework-extends
 * @description:
 * @author: Chenjiabin
 * @create: 2018-04-22 20:29
 **/
@Service
@Transactional
public class OrderService {
    @Autowired
    private OrderMapper orderMapper;

    public List<Order> findAll() {
        return orderMapper.findAll();
    }

    public Page<Order> findAll(int page, int size) {
        //分页插件: 查询第1页，每页10行
        Page<Order> result = PageHelper.startPage(page, size);
        orderMapper.findAll();
        return result;
    }

    public long insert(Order order) {
        return orderMapper.insert(order);
    }
}
